package cn.com.dhcc.app.pub.core.tag.staticcode;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;


/**
 * @author Administrator
 */
public class StaticCode {


    /**
     * 数据源类型
     *
     * @author Administrator
     */
    public static enum DS_TYPE {
        DATA_BASE("1", "数据库"),
        LOCAL_DISK("2", "本地磁盘"),
        FTP("3", "FTP服务器"),
        DATA_SOURCE_EMAIL("4", "邮件服务器"),
        APP_SYSTEM("5", "应用系统");
        private String code;
        private String name;

        public String getCode() {
            return code;
        }

        public String getName() {
            return name;
        }

        private DS_TYPE(String code, String name) {
            this.code = code;
            this.name = name;
        }
    }

    /**
     * 数据库类型
     *
     * @author Administrator
     */
    public static enum DB_TYPE {
        ORACLE("11", "oracle", "oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@127.0.0.1:1521/db_name", "select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual", "SYSDATE"),
        MYSQL("12", "mysql", "com.mysql.jdbc.Driver", "jdbc:mysql://localhost:3306/db_name", "select date_format(NOW(), '%Y-%m-%d %H:%i:%s') from dual", "now()"),
        SQLSERVER("13", "sqlServer", "com.microsoft.sqlserver.jdbc.SQLServerDriver", "jdbc:sqlserver://localhost:1433;DatabaseName=db_name", "SELECT convert(varchar, getdate(), 120)", "getdate()"),
        SQLSERVEREXT("14", "sqlServer(2000)", "com.microsoft.sqlserver.jdbc.SQLServerDriver", "jdbc:sqlserver://localhost:1433;DatabaseName=db_name", "SELECT convert(varchar, getdate(), 120)", "getdate()");

        private String code;
        private String name;
        private String driverName;
        private String linkUrl;
        private String validateUrl;
        private String systime;

        //打印code和name
        public static String toStr() {
            StringBuffer buffer = new StringBuffer();
            DB_TYPE[] types = DB_TYPE.values();
            for (int i = 0; i < types.length; i++) {
                buffer.append(types[i].getCode() + ":" + types[i].getName());
            }
            return buffer.toString();
        }

        public String getLinkUrl() {
            return linkUrl;
        }

        public String getCode() {
            return code;
        }

        public String getName() {
            return name;
        }

        public String getDriverName() {
            return driverName;
        }

        public String getSystime() {
            return systime;
        }

        private DB_TYPE(String code, String name) {
            this.code = code;
            this.name = name;
        }

        public String getValidateUrl() {
            return validateUrl;
        }

        private static final Map lookup = new HashMap();

        static {
            for (DB_TYPE e : EnumSet.allOf(DB_TYPE.class)) {
                lookup.put(e.code, e);
            }
        }

        /**
         * 通code查找value
         *
         * @param code
         * @return
         */
        public static DB_TYPE find(String code) {
            DB_TYPE value = (DB_TYPE) lookup.get(code);
            return value;
        }

        private DB_TYPE(String code, String name, String driverName, String linkUrl, String validateUrl, String systime) {
            this.code = code;
            this.name = name;
            this.driverName = driverName;
            this.linkUrl = linkUrl;
            this.validateUrl = validateUrl;
            this.systime = systime;
        }

    }

    /**
     * 函数类型：1表操作、2表名操作、3字段名操作、4字段值操作
     *
     * @author Administrator
     */
    public static enum FX_TYPE {
        TABLE_BATCH_OPR("1", "表批量操作"),
        TABLE_NAME_OPR("2", "表名操作"),
        TABLE_NAME_BATCH_OPR("3", "表名批量操作"),
        FIELD_NAME_OPR("4", "字段名操作"),
        FIELD_NAME_BATCH_OPR("5", "字段名批量操作"),
        FIELD_VALUE_OPR("6", "字段值操作"),
        FILE_BATCH_OPR("7", "文件名批量操作");
        private String code;
        private String name;

        public String getCode() {
            return code;
        }

        public String getName() {
            return name;
        }

        private FX_TYPE(String code, String name) {
            this.code = code;
            this.name = name;
        }
    }
    
    /**
     * 函数作用在什么类型对象上：1表名、2字段名、3字段值、4文件名
     *
     * @author Administrator
     */
    public static enum FX_ACT_ON_TYPE {
        ACT_TABLE_NAME("1", "表名"),
        ACT_FIELD_NAME("2", "字段名"),
        ACT_FIELD_VALUE("3", "字段值"),
        ACT_FILE_NAME("4", "文件名");
        private String code;
        private String name;

        public String getCode() {
            return code;
        }

        public String getName() {
            return name;
        }

        private FX_ACT_ON_TYPE(String code, String name) {
            this.code = code;
            this.name = name;
        }
    }

    /**
     * 目录类型
     *
     * @author Administrator
     */
    public static enum DIR_TYPE {
        SEND("1", "发送"),
        RECV("2", "接收");
        private String code;
        private String name;

        public String getCode() {
            return code;
        }

        public String getName() {
            return name;
        }

        private DIR_TYPE(String code, String name) {
            this.code = code;
            this.name = name;
        }
    }

    /**
     * 数据源所属系统
     *
     * @author Administrator
     */
    public static enum OWN_SYS_CODE {
        WATERRESOURCE("121212121212", "水资源支撑平台");
        private String code;
        private String name;

        public String getCode() {
            return code;
        }

        public String getName() {
            return name;
        }

        private OWN_SYS_CODE(String code, String name) {
            this.code = code;
            this.name = name;
        }
    }

    public static enum TASK_FREQ_TYPE {
        ONETIME("1", "一次性任务"),
        PERIOD("2", "周期性任务");
        private String code;
        private String name;

        public String getCode() {
            return code;
        }

        public void setCode(String code) {
            this.code = code;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        private TASK_FREQ_TYPE(String code, String name) {
            this.code = code;
            this.name = name;
        }
    }

    public static enum TASK_STATUS {
        STOP("1", "暂停"),
        WAIT("2", "待执行"),
        ING("3", "执行中"),
        OVER("4", "已完成"),
        ERROR("5", "执行失败");
        private String code;
        private String name;

        private TASK_STATUS(String code, String name) {
            this.code = code;
            this.name = name;
        }

        public String getCode() {
            return code;
        }

        public String getName() {
            return name;
        }

    }

    //200 成功; 400参数异常; 500服务器异常
    public static enum API_RESPONSE_STATUS {
        SUCCESS("200", "成功"),
        ARG_ERROR("400", "参数异常"),
        SERVER_ERROR("500", "服务器异常");
        private String code;
        private String name;

        private API_RESPONSE_STATUS(String code, String name) {
            this.code = code;
            this.name = name;
        }

        public String getCode() {
            return code;
        }

        public String getName() {
            return name;
        }

    }

    // 指定频率 1 间隔 2每天3 每周4 每月
    public static enum FREQ_TYPE {
        INTERVAL("1", "间隔"),
        DAYLY("2", "每天"),
        WEEKLY("3", "每周"),
        MONTHLY("4", "每月");
        private String code;
        private String name;

        public String getCode() {
            return code;
        }

        public void setCode(String code) {
            this.code = code;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        private FREQ_TYPE(String code, String name) {
            this.code = code;
            this.name = name;
        }
    }

    // 星期
    public static enum WEEK_TYPE {
        MON("2", "一"),
        TUE("3", "二"),
        WED("4", "三"),
        THU("5", "四"),
        FRI("6", "五"),
        SAT("7", "六"),
        SUN("1", "日");
        private String code;
        private String name;

        public String getCode() {
            return code;
        }

        public void setCode(String code) {
            this.code = code;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        private WEEK_TYPE(String code, String name) {
            this.code = code;
            this.name = name;
        }
    }

    /**
     * 任务执行类型
     */
    public static enum TaskExecuteTypeEnum {
        IMME("1", "立即执行"),
        MANUAL("2", "手动执行"),
        TIMING("3", "定时执行");
        private String code;
        private String name;

        private TaskExecuteTypeEnum(String code, String name) {
            this.code = code;
            this.name = name;
        }

        public String getCode() {
            return code;
        }

        public String getName() {
            return name;
        }
    }

    public static enum EXCH_DATA_STATUS {
        WAIT("1", "待执行"),
        ING("2", "执行中"),
        OVER("3", "执行完成"),
        ERROR("4", "执行失败");
        private String code;
        private String name;

        private EXCH_DATA_STATUS(String code, String name) {
            this.code = code;
            this.name = name;
        }

        public String getCode() {
            return code;
        }

        public String getName() {
            return name;
        }

    }

    public static enum DATA_STATUS {
        DISABLE("0", "停用"),
        ENABLE("1", "启用");
        private String code;
        private String name;

        private DATA_STATUS(String code, String name) {
            this.code = code;
            this.name = name;
        }

        public String getCode() {
            return code;
        }

        public String getName() {
            return name;
        }
    }

    public static enum LINK_TYPE {
        EXTRACT("1", "抽取"),
        TANSFORM("2", "映射"),
        LOAD("3", "加载");
        private String code;
        private String name;
        private static final Map lookup = new HashMap();

        static {
            for (LINK_TYPE e : EnumSet.allOf(LINK_TYPE.class)) {
                lookup.put(e.code, e);
            }
        }

        /**
         * 通code查找value
         *
         * @param code
         * @return
         */
        public static LINK_TYPE find(String code) {
            LINK_TYPE value = (LINK_TYPE) lookup.get(code);
            return value;
        }

        LINK_TYPE(String code, String name) {
            this.code = code;
            this.name = name;
        }

        public String getCode() {
            return code;
        }

        public String getName() {
            return name;
        }
    }

    /**
     * 文件过滤条件类型
     */
    public enum FilterTypeEnum {
        WILDCARD("1", "通配符"),
        REGEXP("2", "正则表达式");
        private String code;
        private String name;

        public String getCode() {
            return code;
        }

        public String getName() {
            return name;
        }

        private FilterTypeEnum(String code, String name) {
            this.code = code;
            this.name = name;
        }

        private static final Map lookup = new HashMap();

        static {
            for (StaticCode.FilterTypeEnum e : EnumSet.allOf(StaticCode.FilterTypeEnum.class)) {
                lookup.put(e.code, e);
            }
        }

        /**
         * 通code查找value
         *
         * @param code
         * @return
         */
        public static StaticCode.FilterTypeEnum find(String code) {
            StaticCode.FilterTypeEnum value = (StaticCode.FilterTypeEnum) lookup.get(code);
            return value;
        }
    }
}
